import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 设备点检配置信息 */
export interface EquipmentCheckConfig {
  id: number // id
  configType: number // 配置类型1按分类2按设备
  targetId: number // 根据配置类型，可能是分类ID或设备ID
  keepSetting: string // 点检项
}

// 设备点检配置 API
export const EquipmentCheckConfigApi = {
  // 查询设备点检配置分页
  getEquipmentCheckConfigPage: async (params: any) => {
    return await request.get({ url: `/business/equipment-check-config/page`, params })
  },

  // 查询设备点检配置详情
  getEquipmentCheckConfig: async (id: number) => {
    return await request.get({ url: `/business/equipment-check-config/get?id=` + id })
  },

  // 新增设备点检配置
  createEquipmentCheckConfig: async (data: EquipmentCheckConfig) => {
    return await request.post({ url: `/business/equipment-check-config/create`, data })
  },

  // 修改设备点检配置
  updateEquipmentCheckConfig: async (data: EquipmentCheckConfig) => {
    return await request.put({ url: `/business/equipment-check-config/update`, data })
  },

  // 删除设备点检配置
  deleteEquipmentCheckConfig: async (id: number) => {
    return await request.delete({ url: `/business/equipment-check-config/delete?id=` + id })
  },

  /** 批量删除设备点检配置 */
  deleteEquipmentCheckConfigList: async (ids: number[]) => {
    return await request.delete({
      url: `/business/equipment-check-config/delete-list?ids=${ids.join(',')}`
    })
  },

  // 批量配置
  batchEquipmentCheckConfig: async (data) => {
    // 改为 data 更清晰
    return await request.post({
      url: `/business/equipment-check-config/batchConfig`,
      data // 明确作为请求体发送
    })
  },

  // 导出设备点检配置 Excel
  exportEquipmentCheckConfig: async (params) => {
    return await request.download({ url: `/business/equipment-check-config/export-excel`, params })
  }
}
